package com.miracle.login.module.mvp.model;

import com.miracle.basemvp.base.BaseModel;
import com.miracle.basemvp.base.BaseResponse;
import com.miracle.basemvp.lifecycle.rx.RxSchedulersHelper;
import com.miracle.basemvp.network.IRetrofitManager;
import com.miracle.login.module.api.LoginApi;
import com.miracle.login.module.mvp.contract.RegisterContract;
import com.miracle.login.module.mvp.entity.request.RegisterRequest;
import com.miracle.login.module.mvp.entity.response.LoginResponse;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * com.miracle.login.module.mvp.model
 * (c)2018 AIR Times Inc. All rights reserved.
 *
 *
 * @author WangJQ
 * @version 1.0
 * @date 2018/7/5 14:19
 * @see com.miracle.login.module.mvp.model
 */
public class RegisterModel extends BaseModel implements RegisterContract.Model {

    @Inject
    public RegisterModel(IRetrofitManager retrofitManager) {
        super(retrofitManager);
    }

    @Override
    public Observable<BaseResponse<String>> register(RegisterRequest request) {
        return mRetrofitManager
                .obtainRetrofitService(LoginApi.class)
                .register(request)
                .compose(RxSchedulersHelper.<BaseResponse<String>>io_main());
    }
}
